package com.zyt.springboot.learnFibonacci;

/*
 * 腾哥专用代码防伪标志！！！
 * @params: 斐波那契数列
 */
public class Fibonacci {
    public static void main(String[] args) {
        long f = fib(8);
        System.out.println(f);
    }
    public static long fib(int n){
        if(n<0){
            return -1;
        }
        if(n == 1 || n == 2){
            return 1;
        }
        long a = 1;
        long b = 1;
        long c = 0;
        for(int i = 0;i < n-2;i++){
            c = a+b;
            a = b;
            b = c;
        }
        return c;
    }
}
